package com.exam.api.modules.student.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.exam.api.modules.student.domain.TblStudent;
import com.exam.api.modules.student.mapper.TblStudentMapper;
import com.exam.api.modules.student.service.TblStudentService;
import org.springframework.stereotype.Service;

@Service
public class TblStudentServiceImpl extends ServiceImpl<TblStudentMapper, TblStudent> implements TblStudentService {

    @Override
    public TblStudent getStudentByTel(String tel) {
        return lambdaQuery().eq(TblStudent::getPhone, tel).oneOpt().orElseGet(()->{
            TblStudent student = new TblStudent();
            student.setPhone(tel);
            save(student);
            return student;
        });
    }
}
